#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
void reverse(char* start, char* end)
{
	while (start < end)
	{
		char temp[10000] = "0";
		temp[0] = *end;
		*end = *start;
		*start = temp[0];
		start++;
		end--;
	}
}
void Left(char* p, int len, int k)
{
	int time = k % len;
	reverse(p, p + time - 1);
	reverse(p + time, p + len - 1);
	reverse(p, p + len - 1);
}

int main()
{
	char arr[10000] = "0";
	gets(arr);
	char* p = arr;
	int k = 0;
	scanf("%d", &k)!=EOF;
	int len = strlen(p);
	Left(p, len, k);
	printf("%s", p);
	return 0;
}